<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--
  Created by IntelliJ IDEA.
  User: 15c
  Date: 2018/1/27
  Time: 1:22
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<html>

<head>
    <title>知游管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css"
          href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/indexStyle.css">
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/resource/bootstrap-3.3.7-dist/css/flat-blue.css">
    <style>
        .nav-li:hover {
            border-bottom: 1px solid #ccc
        }

        .table th, .table td {
            text-align: center;
            vertical-align: middle !important;
        }

        .btm-input {
            border-radius: 5px
        }


    </style>
    <%--获取时间--%>
    <script type="text/javascript">
        function setDateTime() {
            var date = new Date();
            var day = date.getDay();
            var week;
            switch (day) {
                case 0:
                    week = "星期日";
                    break;
                case 1:
                    week = "星期一";
                    break;
                case 2:
                    week = "星期二";
                    break;
                case 3:
                    week = "星期三";
                    break;
                case 4:
                    week = "星期四";
                    break;
                case 5:
                    week = "星期五";
                    break;
                case 6:
                    week = "星期六";
                    break;
            }
            var hours = (date.getHours() < 10) ? "0" + date.getHours() : date.getHours();
            var minutes = (date.getMinutes() < 10) ? "0" + date.getMinutes() : date.getMinutes();
            var seconds = (date.getSeconds() < 10) ? "0" + date.getSeconds() : date.getSeconds();
            var today = date.getFullYear() + "年" + (date.getMonth() + 1) + "月"
                + date.getDate() + "日 " + week + " " + hours + ":"
                + minutes + ":" + seconds;
            document.getElementById("today").innerHTML = today;
        }
        window.setInterval("setDateTime()", 1000);
    </script>

</head>

<body class="flat-blue">
<div class="app-container">
    <div class="row content-container">
        <nav class="navbar navbar-default navbar-fixed-top navbar-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-expand-toggle">
                        <span class="fa fa-bars icon"></span>
                    </button>
                    <ol class="breadcrumb navbar-breadcrumb">
                        <li class="active">查看课程</li>
                    </ol>
                    <button type="button" class="navbar-right-expand-toggle pull-right visible-xs">
                        <span style="font-size: 18px" class="glyphicon glyphicon-chevron-left"></span>
                    </button>
                </div>
                <ul class="nav navbar-nav navbar-right">
                    <button type="button" class="navbar-right-expand-toggle pull-right visible-xs">
                        <span style="font-size: 18px" class="glyphicon glyphicon-chevron-up"></span>
                    </button>
                    <%
                        if (null != session.getAttribute("admin")) {%>
                    <li class="admin" style="float: left">
                        <img class="img-responsive" width="80%" height="80%"
                             src="${pageContext.request.contextPath}/images/avtar.png"/>
                    </li>
                    <li class="admin" style="float: left;margin-right: 20px">
                        <h5>欢迎管理员：<span style="color: #dd3e3e"><%=session.getAttribute("admin")%></span></h5>
                        <i class="glyphicon glyphicon-time"></i><span id="today"></span>
                    </li>
                    <%}%>
                </ul>
            </div>
        </nav>
        <div class="side-menu sidebar-inverse">
            <nav class="navbar navbar-default" role="navigation">
                <div class="side-menu-container">
                    <div class="navbar-header">
                        <a class="navbar-brand" href="#">
                            <div class="icon fa  fa-mortar-board"></div>
                            <div class="title">ZhiYou Management
                            </div>
                        </a>
                        <button type="button" class="navbar-expand-toggle pull-right visible-xs">

                        </button>
                    </div>
                    <ul class="nav navbar-nav">
                        <li class="nav-li">
                            <a href="${pageContext.request.contextPath}/index">
                                <span class="icon fa   fa-bars"></span><span class="title">首页</span>
                            </a>
                        </li>
                        <li class="nav-li">
                            <a href="${pageContext.request.contextPath}/admin/list">
                                <span class="icon fa fa-user"></span><span class="title">查看用户</span>
                            </a>

                        </li>
                        <li class="nav-li">
                            <a href="${pageContext.request.contextPath}/admin/show/type">
                                <span class="icon fa fa-pencil"></span><span class="title">添加类型</span>
                            </a>

                        </li>
                        <li class="nav-li">
                            <a href="${pageContext.request.contextPath}/admin/classlist">
                                <span class="icon fa fa-file-o"></span><span class="title">查看课程</span>
                            </a>

                        </li>


                        <li class="nav-li">
                            <a href="${pageContext.request.contextPath}/admin/add/class">
                                <span class="icon fa fa-pencil-square-o"></span><span class="title">添加课程</span>
                            </a>

                        </li>

                        <li id="login-li" class="nav-li">
                            <%--"<% if (null == session.getAttribute("admin")) {%>--%>
                            <%--${pageContext.request.contextPath}/login--%>
                            <%--<%}else {%>--%>
                            <%--<%}%>"--%>
                            <a id="login-a" href="">
                                <span class="icon fa fa-paw"></span><span class="title">登录系统</span>
                            </a>

                        </li>

                        <li id="loginOut-li" class="nav-li">
                            <a id="loginOut-a" href="" onclick="check()">
                                <span class="icon fa fa-reply"></span><span class="title">退出系统</span>
                            </a>

                        </li>
                    </ul>
                </div>

            </nav>
        </div>

        <!-- Main Content -->

        <div class="container-fluid">
            <div class="side-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="card">
                            <div class="card-header">

                                <div class="card-title">
                                    <div class="title"><span style="font-size: 14px">检索课程</span></div>

                                    <sf:form method="get"
                                             action="${pageContext.request.contextPath}/admin/class/retrieval">
                                        <input style="border-radius: 6px;box-shadow: none; " type="text"
                                               name="keyword"/>
                                        <input class="btn-success btm-input" type="submit" value="检索"/>
                                    </sf:form>
                                    <div style="margin-top: 3%">
                                        <a style="font-size: 18px;font-weight: bold;color: #1d7dff"
                                           href="${pageContext.request.contextPath}/admin/add/class">点击添加课程</a>
                                    </div>
                                </div>
                            </div>
                            <div class="card-body">
                                <div style="font-size: 10px;font-weight: bold;color: #ea2530">
                                    课程状态（0：上架，1：下架）
                                </div>
                                <table class="datatable table table-striped" cellspacing="0" width="100%"
                                       style="font-size: 8px">
                                    <thead>
                                    <tr>
                                        <th>课程id</th>
                                        <th>课程标题</th>
                                        <th>课程简介</th>
                                        <th>课程评分</th>
                                        <th>课程适应人群</th>
                                        <th>课程价格</th>
                                        <th>课程图片</th>
                                        <th>课程学习人数</th>
                                        <th>课程发布时间</th>
                                        <th>课程类型一</th>
                                        <th>课程类型二</th>
                                        <th>课程类型三</th>
                                        <th>课程状态</th>

                                        <%--<th >执行操作</th>--%>

                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${pager.datas}" var="course">
                                        <tr>
                                            <td>${course.classId}</td>
                                            <td>${course.classTitle}</td>
                                            <td>${course.classDetail}</td>
                                            <td>${course.classEvaluateGrade}</td>
                                            <td>${course.classApplyPeople}</td>
                                            <td>${course.classPrice}</td>
                                            <td>
                                                <img id="classImg" width="50px" height="50px"
                                                     alt='暂无图片' src="${pageContext.request.contextPath}/resources/classImg/${course.classImg}"/>
                                            </td>
                                            <td>${course.classCount}</td>
                                            <td>
                                                <fmt:formatDate value="${course.classTime}" pattern="yyyy-MM-dd"/>

                                            </td>
                                            <td>${course.typeName1}</td>
                                            <td>${course.typeName2}</td>
                                            <td>${course.typeName3}</td>
                                            <td>${course.classState}</td>

                                            <td>


                                                <button class="	btn btn-warning btm-input"><a
                                                        style="color:#fff;font-size: 8px"
                                                        href="${pageContext.request.contextPath}/admin/update/class?classId=${course.classId}">修改</a>
                                                </button>

                                                <button class="	btn btn-info btm-input"><a
                                                        style="color:#fff;font-size: 8px"
                                                        href="${pageContext.request.contextPath}/admin/linelist?classId=${course.classId}">查看线路</a>
                                                </button>

                                            </td>

                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                    <tr>
                                        <td colspan="14" align="center">
                                            <pg:pager items="${pager.totalRecord}" maxPageItems="${pager.pageSize}"
                                                      url="classlist" maxIndexPages="10" export="curPage=pageNumber">
                                                共有<span style="color: red;">${pager.totalPage}</span>页 当前是第<span style="color: red"><%=curPage%></span>页
                                                <pg:first>
                                                    <button style="  border-radius: 5px" class="btn btn-info"><a
                                                            style="font-size: 5px"
                                                            href="${pageUrl}">首页</a></button>
                                                </pg:first>
                                                <pg:prev>
                                                    <button style="  border-radius: 5px" class="btn btn-info"><a
                                                            style="font-size: 5px"
                                                            href="${pageUrl}">上一页</a>
                                                    </button>
                                                </pg:prev>
                                                <pg:pages>
                                                    <c:if test="${curPage eq  pageNumber}">
                                                        <button style="  border-radius: 5px"
                                                                class="btn btn-default"><span
                                                                style="color: red;font-weight: bold"><%=pageNumber%></span>
                                                        </button>
                                                    </c:if>
                                                    <c:if test="${curPage ne pageNumber}">
                                                        <button style="  border-radius: 5px" class="btn btn-default"><a
                                                                style="font-size: 5px"
                                                                href="${pageUrl}">${pageNumber}
                                                        </a></button>
                                                    </c:if>
                                                </pg:pages>
                                                <pg:next>
                                                    <button style="  border-radius: 5px" class="btn btn-info"><a
                                                            style="font-size: 5px"
                                                            href="${pageUrl}">下一页</a></button>
                                                </pg:next>
                                                <pg:last>
                                                    <button style="  border-radius: 5px" class="btn btn-info"><a
                                                            style="font-size: 5px"
                                                            href="${pageUrl}">尾页</a></button>
                                                </pg:last>
                                            </pg:pager>
                                        </td>

                                    </tr>
                                </table>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<%--弹出窗--%>

</body>


<!-- Javascript Libs -->
<script type="text/javascript"
        src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<script type="text/javascript"
        src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>

<!-- Javascript -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/indexApp.js"></script>


<script type="text/javascript">
    var admin = <%=session.getAttribute("admin")%>;


    //登录验证
    $("#login-li").click(function () {
        if (admin != null) {
            alert("你已经登录")
        } else {
            $("#login-a").attr('href', '${pageContext.request.contextPath}/login');
        }
    });

    //登出验证
    $("#loginOut-li").click(function () {
        if (admin == null) {
            alert("你还未登录")
        } else {
            if (confirm("您确定要退出吗?")) {
                $("#loginOut-a").attr('href', '${pageContext.request.contextPath}/logout?uname=' + admin);

            }

        }


    });


</script>
<script>
    //    课程更新
    var type = "<%=session.getAttribute("class-update-type")%>";
    if (type == "ok") {
        (function foo() {
            alert("课程更新成功");
            <%session.removeAttribute("class-update-type");%>
        })
        ();
    } else if (type == "error") {
        (function foo() {
            alert("课程更新失败");
            <%session.removeAttribute("class-update-type");%>
        })
        ();
    }
    //    课程添加
    var add_type = "<%=session.getAttribute("class-add-type")%>";
    if (add_type == "ok") {
        (function foo() {
            alert("课程添加成功");
            <%session.removeAttribute("class-add-type");%>
        })
        ();
    } else if (add_type == "error") {
        (function foo() {
            alert("课程添加失败");
            <%session.removeAttribute("class-add-type");%>
        })
        ();
    }


</script>

</html>


